错误 Missing classes
1 | Missing classes |
解决方法:去掉布局文件中,不存在的 viewModel 对象的引用。重新 build,就可以了。
error: Error: Dimension types not allowed (at ‘shadowDx’ with value ‘5dp’
1 | <TextView |
改了只后,还出错,而且,XML中的值被改回去。仔细看错误发现,错误指向的XML不是原始文件:D:\\work\\videoshare_android.git\\app\\build\\intermediates\\data-binding-layout-out\\_360\\debug\\layout\\activity_camera_record_video_layout.xml
错误 Using the design library requires using Theme.AppCompat or a descendant
1 | Using the design library requires using Theme.AppCompat or a descendant |
配置清单
解决方法
删除 PlayerActivity 的 android:theme="@style/AppTheme.NoActionBar"
即使用 <application>
指定的样式 android:theme="@style/AppTheme"
或者给 @style/AppTheme.NoActionBar
增加父样式 Theme.AppCompat
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity android:name=".LansoDemoActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name=".PlayerActivity"
android:label="@string/title_activity_player"
android:theme="@style/AppTheme.NoActionBar">
</activity>
</application>
@style/AppTheme.NoActionBar 和 @style/AppTheme 样式的代码1
2
3
4
5
6
7
8
9
10
11
12<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<!-- Customize your theme here. -->
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorAccent">@color/colorAccent</item>
</style>
<style name="AppTheme.NoActionBar">
<item name="windowActionBar">false</item>
<item name="windowNoTitle">true</item>
</style>
gradle.build 指定的依赖1
2
3compile 'com.android.support:appcompat-v7:25.3.1'
compile 'com.android.support.constraint:constraint-layout:1.0.2'
compile 'com.android.support:design:25.3.1'
出错的 Activity 的定义1
public class PlayerActivity extends AppCompatActivity
出错的布局1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="work.wangxiang.lansodemo.PlayerActivity">
<android.support.design.widget.AppBarLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:theme="@style/AppTheme.AppBarOverlay">
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="?attr/colorPrimary"
app:popupTheme="@style/AppTheme.PopupOverlay" />
</android.support.design.widget.AppBarLayout>
<include layout="@layout/content_player" />
<android.support.design.widget.FloatingActionButton
android:id="@+id/fab"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="bottom|end"
android:layout_margin="@dimen/fab_margin"
app:srcCompat="@android:drawable/ic_dialog_email" />
</android.support.design.widget.CoordinatorLayout>
把 activity 样式回复成原来的,重新打开 AS,又不出错了。
错误:Layout fidelity warning
1 | <TextView |
accurate
英 [ˈækjərət] 美 [ˈækjərɪt]
adj.精确的,准确的;正确无误的
fidelity
英 [fɪˈdeləti] 美 [fɪˈdɛlɪti,faɪ-]
n.保真度;逼真;忠诚,忠实;尽责
The graphics preview in the layout editor may not be accurate:
Paint.setShadowLayer is not supported
error-the-graphics-preview-in-the-layout-editor-may-not-be-accurate-paint-set
It means the preview doesn’t know how to implement setShadowLayer. This means the preview won’t look exactly like the result rendered on the device. Which is one of many reasons why you shouldn’t trust the preview app- always test your layouts on a physical device before assuming they’re done.